#pragma once
#ifndef __MATERIAL__TEMPLATE_GENERATOR__HH__
#define __MATERIAL__TEMPLATE_GENERATOR__HH__

//#include <Ogre.h>
#include <LitPrerequisites.h>

namespace Lit
{
	namespace Editor
	{
		namespace Material
		{
			class LIT_API CScriptParser
			{
			public:
				enum TokenType
				{
					Char,
					Comment,
					BlockBegin,
					BlockEnd,
					ArgBlockBegin,
					ArgBlockEnd,
					SemiColon 
				};
				
				static const String::char_type BlockBeginChar = '{';
				static const String::char_type BlockEndChar = '}';
				static const String::char_type ArgBlockBeginChar = '(';
				static const String::char_type ArgBlockEndChar = ')';
				static const String::char_type SemiColonChar = ';';

				struct Node
				{
					Node( Node * parent_ ) : parent( parent_ ){}
					Node( const String &name_="", const String &args_ = "", Node * parent_ = NULL ) : name(name_), args(args_), parent( parent_ ){}
					Node( const Node& rk ) : name(rk.name), args(rk.args), parent( rk.parent ), nodes(rk.nodes){}
					~Node(){}
					
					Node& operator=( const Node& rk ){ name=rk.name; args=rk.args; parent = rk.parent; nodes = rk.nodes; return *this; }

					Node& createChild( const String &name_="", const String &args_ = "" )
					{
						nodes.push_back( Node( name_, args_, this ) );
						return nodes.at(nodes.size()-1);
					}
					Node* parent;
					String args;
					String name;
					std::vector<Node> nodes;
				};
			protected:
				Node mRoot;
				Node &pHead;
			public:
				CScriptParser();
				CScriptParser(const CScriptParser& rk );
				~CScriptParser();

				Node& popHead();
				Node& pushHead( const String &this_name, bool same_level = false, const String &this_args = "" );

				String	indent( size_t num );
				String printNode( Node * node = NULL, size_t ind = 0 );

				void parse( const String &text );

				const Node* getRootNode() const;
				Node* getRootNode() ;
			};
		};
	};
};

#endif